#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;

#endregion

namespace TVC.Forms
{
    public partial class frmSYS : Form
    {
        DataRow _returnValue = null;

        public DataRow ReturnValue
        {
            get { return _returnValue; }
            set { _returnValue = value; }
        }
        public frmSYS()
        {
            InitializeComponent();
        }

        private void frmPOG_Load(object sender, EventArgs e)
        {
            dgvList.AutoGenerateColumns = false;
            Rebind();
        }

        private void Rebind()
        {
            string tempPath = Context.HttpContext.Request.MapPath("/") + Properties.Settings.Default.ConfigPath + "Struct.xml";
            DataSet ds = new DataSet();
            ds.ReadXml(tempPath);
            if (ds.Tables.Contains("Struct"))
            {
                ds.Tables["Struct"].PrimaryKey = new DataColumn[] { ds.Tables["Struct"].Columns["Code"] };
                bisSys.DataSource = ds.Tables["Struct"];
            }
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            Rebind();
        }

        private void dgvList_DoubleClick(object sender, EventArgs e)
        {
            if (dgvList.CurrentCell != null)
            {
                _returnValue = ((DataRowView)dgvList.CurrentRow.DataBoundItem).Row;
                DialogResult = DialogResult.OK;
                Close();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (dgvList.CurrentCell != null)
            {
                _returnValue = ((DataRowView)dgvList.CurrentRow.DataBoundItem).Row;
                DialogResult = DialogResult.OK;
                Close();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}